<?php
/**
 * 
 * @authors Liujinbi (857053791@QQ.com)
 * @date    2017-09-07 11:35:26
 * @version $Id$
 */
namespace app\agent\controller;

use think\Db;
use think\Controller;
use Godok\Org\Auth;
use think\Config;

class Shopbase extends Base {
    
    function __construct(){
        parent::__construct();
        $shop_id = Request()->param('shop_id',0);
        !$shop_id && $this->error('参数错误');
        $this->shop_id = $shop_id;

        // 检查管家是否有权操作该店铺
        $hasRight = Db::table('sdzx_shop')->alias('s')
        ->join('sdzx_user u','s.user_id=u.id')
        ->where("s.agent_id={$this->uid} and s.shop_id={$shop_id}")->find();

        !$hasRight && $this->error('无权操作该店铺');
        $this->assign('shop_id',$shop_id);

        $this->shop_uid = $hasRight['user_id']?:0;
        !$this->shop_uid && $this->error('参数错误');

        $this->shop_user = $hasRight;
        $this->assign('user',$this->shop_user);
    }
}